#error - Update following Doxygen template
/////////////////////////////////////////////////////////////////////////////
/// @file etudiant.cpp
///
/// Contains [class] object implementations.
///
/// @see [Ss][Class].hpp for a detailed description of this class.
///
/// @par Edit History
/// - [0]   guilhem2 16-JUN-2009 Initial revision of file.
///
/// @par Copyright &copy; 2009 Your Company, Inc. All rights reserved.
///
/// @ingroup [ss]
/////////////////////////////////////////////////////////////////////////////

#include "etudiant.h"

//////////////////////////////etudiant////////////////////////////////////////////////////////////////


int Student::maxId= 0;

#error - Update following Doxygen template
/////////////////////////////////////////////////////////////////////////////
//  Method: Student::SelectSemestre
//
/// [Add brief one sentence description.]
///
/// [Add detailed description, remove if not needed.  Note, the brief
///  description will appear with the detailed description.]
///
/// @note [Add note text if necessary, otherwise remove this line.]
///
/// @param[in,out] num [Add parameter description (remove line when no params).]
///
/// @return Semestre* [Add description of what is returned (remove line when nothing returned).]
/// @retval [Add description of a specific return value (remove line when nothing returned).]
/////////////////////////////////////////////////////////////////////////////
Semestre* Student::SelectSemestre(int num)
{
    if (num==0)
        return &semesterList.back();
    list<Semestre>::reverse_iterator rit;
    for (rit=semesterList.rbegin(); rit!=semesterList.rend(); ++rit)
    {
        if (rit->GetNumber() ==num)
            return &(*rit);
    }
}

#error - Update following Doxygen template
/////////////////////////////////////////////////////////////////////////////
//  Method: Student::AddSemester
//
/// [Add brief one sentence description.]
///
/// [Add detailed description, remove if not needed.  Note, the brief
///  description will appear with the detailed description.]
///
/// @note [Add note text if necessary, otherwise remove this line.]
/////////////////////////////////////////////////////////////////////////////
void Student::AddSemester()
{
    int num;

    if (semesterList.empty())
    {
        num=1;
    }
    else
    {
        num = semesterList.back().GetNumber();
        num++;
    }

    Semestre s2(num);
    semesterList.push_back(s2);
}

#error - Update following Doxygen template
/////////////////////////////////////////////////////////////////////////////
//  Method: Student::RmSemester
//
/// [Add brief one sentence description.]
///
/// [Add detailed description, remove if not needed.  Note, the brief
///  description will appear with the detailed description.]
///
/// @note [Add note text if necessary, otherwise remove this line.]
///
/// @param[in,out] num [Add parameter description (remove line when no params).]
/////////////////////////////////////////////////////////////////////////////
void Student::RmSemester(int num)
{
    if (num==0)
    {
        semesterList.erase(--semesterList.end());
    }
    else
    {
        list<Semestre>::iterator it;
        for (it=semesterList.begin(); it!=semesterList.end(); ++it)
        {
            if (it->GetNumber() ==num)
            {
                semesterList.erase(it);
                break;
            }
        }
    }
}

#error - Update following Doxygen template
/////////////////////////////////////////////////////////////////////////////
//  Method: Student::Affiche
//
/// [Add brief one sentence description.]
///
/// [Add detailed description, remove if not needed.  Note, the brief
///  description will appear with the detailed description.]
///
/// @note [Add note text if necessary, otherwise remove this line.]
///
/// @param[in,out] &s [Add parameter description (remove line when no params).]
/////////////////////////////////////////////////////////////////////////////
//Affichage
void Student::Affiche(ostream &s)
{
    list<Semestre>::iterator it;
    s<<firstName << "   " << lastName <<"   " << branche << endl;

    for (it=semesterList.begin(); it!=semesterList.end(); ++it)
    {
        s << endl<< "--------------------------------" << endl;
        it->affiche(s);

    }
    s << endl<< "===========================================" << endl;

}

#error - Update following Doxygen template
/////////////////////////////////////////////////////////////////////////////
//  Method: Semestre::affiche
//
/// [Add brief one sentence description.]
///
/// [Add detailed description, remove if not needed.  Note, the brief
///  description will appear with the detailed description.]
///
/// @note [Add note text if necessary, otherwise remove this line.]
///
/// @param[in,out] &s [Add parameter description (remove line when no params).]
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////////SEMESTRE///////////////////////////////////////////////////////////


void Semestre::affiche(ostream &s)
{
    string periode;
    list<Uv>::iterator it;
    if (season==false) periode="d'Automne";
    else periode="de Printemps";
    s<<"semestre "<<number<< "  semestre " << periode <<endl;
    for (it=uvList.begin(); it!=uvList.end(); ++it)
        cout << " " << *it;
}

#error - Update following Doxygen template
/////////////////////////////////////////////////////////////////////////////
//  Method: Semestre::AddUv
//
/// [Add brief one sentence description.]
///
/// [Add detailed description, remove if not needed.  Note, the brief
///  description will appear with the detailed description.]
///
/// @note [Add note text if necessary, otherwise remove this line.]
///
/// @param[in,out] id [Add parameter description (remove line when no params).]
/////////////////////////////////////////////////////////////////////////////
void Semestre::AddUv(string id)
{
    Uv newUv(id);
    list<Uv>::iterator it;
    if (uvList.size() >= 7) cout<<"trop d'uv"<<endl;
    else
    {
        for (it=uvList.begin(); it!=uvList.end(); ++it)
            if (it->GetCodeUv() == id)
            {
                cout << "UV deja ajoutee" << endl;
                return;
            }
        uvList.push_back (newUv);
    }
}

#error - Update following Doxygen template
/////////////////////////////////////////////////////////////////////////////
//  Method: Semestre::SetUv
//
/// [Add brief one sentence description.]
///
/// [Add detailed description, remove if not needed.  Note, the brief
///  description will appear with the detailed description.]
///
/// @note [Add note text if necessary, otherwise remove this line.]
///
/// @param[in,out] id [Add parameter description (remove line when no params).]
/// @param[in,out] note [Add parameter description (remove line when no params).]
/////////////////////////////////////////////////////////////////////////////
void Semestre::SetUv(string id, string note)
{
    list<Uv>::iterator it;
    for (it=uvList.begin(); it!=uvList.end(); ++it)
        if (it->GetCodeUv() == id)
        {
            it->SetResult(note);
            return;
        }
    cout << "UV absente de la liste" << endl;
}

#error - Update following Doxygen template
/////////////////////////////////////////////////////////////////////////////
//  Method: Semestre::RmvUv
//
/// [Add brief one sentence description.]
///
/// [Add detailed description, remove if not needed.  Note, the brief
///  description will appear with the detailed description.]
///
/// @note [Add note text if necessary, otherwise remove this line.]
///
/// @param[in,out] id [Add parameter description (remove line when no params).]
/////////////////////////////////////////////////////////////////////////////
void Semestre::RmvUv(string id)
{
    list<Uv>::iterator it;
    for (it=uvList.begin(); it!=uvList.end(); ++it)
        if (it->GetCodeUv() == id)
        {
            uvList.erase(it);
            return;
        }
    cout<< "UV inexistante dans la liste" << endl;
}



///////////////////////////////////UV//////////////////////////////////////////////////////////////////

ostream& operator<<(ostream &s, Uv &u)
{
    s << "UV: "<< u.GetCodeUv() << endl;
    if (u.GetResult() != "00")
        s << "Resultat: "<< u.GetResult() << endl<<endl;
    return s;
}

